<?php
include_once 'config.php';
$_SESSION['Response'] = 0;
if ($_POST != NULL) {
	if(isset($_POST['Publish'])){
		$Json = json_decode($_POST['Publish']);
		TopicPublish($Json->TopicTitle,$Json->TopicContent,$Json->TopicClassId);
	}
}
echo $_SESSION['Response'];
function TopicPublish($TopicTitle,$TopicContent,$TopicClassId){
	$Link_mysql = mysqli_connect(Server, User, Pwd, Database);
	$SqlInsert = "insert into topics(topic_title,topic_content,users_user_id,topicclass_topicclass_id) values('" . $TopicTitle . "','".$TopicContent."',".$_SESSION['user']['user_id'].",".$TopicClassId.")";
	if ($Link_mysql -> query($SqlInsert)) {
		$_SESSION['Response'] = 106;//发表成功
	}
	else{
		echo $SqlInsert;
		$_SESSION['Response'] = 107;//发表失败
		echo mysqli_error($Link_mysql);
	}
	mysqli_close($Link_mysql);
}
?>